package com.ruoyi.core.domain.custombean;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.utils.DateUtils;
import lombok.Data;
import org.springframework.util.Assert;

import java.util.Date;
import java.util.List;

@Data
public class ClientUserListQueryResult {

    /**
     * 用户id
     */
    private Long id;

    /**
     * 用户名
     */
    @Excel(name = "用户名")
    private String username;

    /**
     * 用户名密码
     */
    @Excel(name = "密码")
    private String password;

    @Excel(name = "主账户管理")
    private String operateUsername;

    /**
     * 状态
     */
    @Excel(name = "是否激活", readConverterExp = "0=激活,1=停用,2=删除")
    private Integer status;

    /**
     * 创建时间
     */
    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date activeTime;

    /**
     * 过期时间
     */
    @Excel(name = "到期时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date expireTime;

    /**
     *
     */
    @Excel(name = "时长")
    private String duration;

    /**
     * 在线状态
     */
    @Excel(name = "在线状态", readConverterExp = "true=在线,false=离线")
    private Boolean online;

    @Excel(name = "权限数")
    private Integer products;

    @Excel(name = "当前登录信息")
    private Integer productUsers;

    private String ckCode;

    private String remark;

    public String getDuration() {
        Assert.notNull(this.activeTime, "客户端用户创建时间不允许为空");
        Assert.notNull(this.expireTime, "客户端用户到期时间不允许为空");
        this.duration = DateUtils.getDatePoorOnDayAndHour(this.expireTime, this.activeTime);
        return duration;
    }

}
